﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Text;
using System.Windows.Forms;

using WFL.Windows.Forms.Theme;

namespace WFL.Demo.WinForm
{
    public partial class SkinForm : Form
    {
        private AsmSkin _asmSkin;

        public SkinForm()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en-US");
            listBox1.DisplayMember = "Name";
            listBox1.ValueMember = "Id";
            _asmSkin = new AsmSkin(Assembly.GetExecutingAssembly());
            IList<SkinItem> list = _asmSkin.GetList();
            listBox1.DataSource = list;
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox listBox = sender as ListBox;
            string id = listBox.SelectedValue.ToString();
            _asmSkin.Load(id);
            RefreshUI();
        }

        private void RefreshUI()
        {
            //label1.Text = _asmSkin.GetStyle("label1").GetValue<string>("Text");
            //pictureBox1.Image = _asmSkin.GetStyle("pictureBox1").GetValue<Image>("Image");
            //skinUserControl1.Title = _asmSkin.GetStyle("skinUserControl1").GetValue<string>("Title");
            _asmSkin.GetStyle("label1").Apply(label1);
            _asmSkin.GetStyle("pictureBox1").Apply(pictureBox1);
            _asmSkin.GetStyle("skinUserControl1").Apply(skinUserControl1);
        }


    }
}
